Page({
  data: {
    searchQuery: '',  // 搜索框的输入内容
    canteens: [
      { 
        id: 1, 
        name: '东园食堂一楼',  
        address: '食堂地址：爱因斯坦广场东南侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-20:00', 
        phone: '027-87792011' 
      },
      { 
        id: 2, 
        name: '东园食堂二楼',  
        address: '食堂地址：爱因斯坦广场东南侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-20:00', 
        phone: '027-87792013' 
      },
      { 
        id: 3, 
        name: '东园食堂三楼',  
        address: '食堂地址：爱因斯坦广场东南侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-20:00', 
        phone: '027-87792012' 
      },
      { 
        id: 4, 
        name: '韵苑食堂一楼',  
        address: '食堂地址：东操场北侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-20:00', 
        phone: '027-87793439' 
      },
      { 
        id: 5, 
        name: '韵苑食堂二楼', 
        address: '食堂地址：东操场北侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-20:00', 
        phone: '027-87792010' 
      },
      { 
        id: 6, 
        name: '学一食堂一楼', 
        address: '食堂地址：东操场南侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-20:00', 
        phone: '027-87792006' 
      },
      { 
        id: 7, 
        name: '学一食堂二楼',  
        address: '食堂地址：东操场南侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-20:00', 
        phone: '027-87792006' 
      },
      { 
        id: 8, 
        name: '学二食堂', 
        address: '食堂地址：东操场南侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-20:00', 
        phone: '027-87792007' 
      },
      { 
        id: 9, 
        name: '东教工食堂', 
        address: '食堂地址：东区医院西南50米', 
        serviceTime: '早餐6:50-9:30，午餐11:00-13:00，晚餐16:30-19:00', 
        phone: '027-87793171' 
      },
      { 
        id: 10, 
        name: '东三食堂', 
        address: '食堂地址：中心操场东北侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-19:00', 
        phone: '027-87542732' 
      },
      { 
        id: 11, 
        name: '东一食堂一楼', 
        address: '食堂地址：中心操场北侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐16:30-22:00', 
        phone: '027-87544094' 
      },
      { 
        id: 12, 
        name: '东一食堂二楼', 
        address: '食堂地址：中心操场北侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐16:30-22:00', 
        phone: '027-87542832' 
      },
      { 
        id: 13, 
        name: '紫荆园风味食堂', 
        address: '食堂地址：中心操场东北侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-14:00，晚餐16:30-20:00', 
        phone: '027-87543009' 
      },
      { 
        id: 14, 
        name: '集贤楼食堂', 
        address: '食堂地址：管理学院东南侧', 
        serviceTime: '早餐6:30-9:00，午餐11:00-13:00，晚餐17:00-19:00', 
        phone: '027-87542633' 
      },
      { 
        id: 15, 
        name: '集锦园食堂', 
        address: '食堂地址：校医院南侧', 
        serviceTime: '早餐6:30-10:00，午餐11:00-13:00，晚餐16:30-19:00', 
        phone: '027-87542334' 
      },
      { 
        id: 16, 
        name: '喻园风味食堂', 
        address: '食堂地址：集贸市场南侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:30，晚餐16:30-20:00', 
        phone: '027-87544768' 
      },
      { 
        id: 17, 
        name: '百景园食堂一楼', 
        address: '食堂地址：西边高层小区西南侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-19:00', 
        phone: '027-87556921' 
      },
      { 
        id: 18, 
        name: '百景园食堂二楼', 
        address: '食堂地址：西边高层小区西南侧', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-19:00', 
        phone: '027-87556922' 
      },
      { 
        id: 19, 
        name: '西一食堂一楼', 
        address: '食堂地址：西操场北侧20米', 
        serviceTime: '早餐6:50-9:30，午餐11:00-13:00，晚餐17:00-19:00', 
        phone: '027-87558601' 
      },
      { 
        id: 20, 
        name: '西一食堂二楼', 
        address: '食堂地址：西操场北侧20米', 
        serviceTime: '早餐6:50-9:30，午餐11:00-13:00，晚餐17:00-19:00', 
        phone: '027-87541802' 
      },
      { 
        id: 21, 
        name: '西一食堂（民族）', 
        address: '食堂地址：西操场北侧20米', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-19:00', 
        phone: '027-87544440' 
      },
      { 
        id: 22, 
        name: '西二食堂一楼', 
        address: '食堂地址：西操场西侧20米', 
        serviceTime: '早餐6:50-9:30，午餐11:00-13:00，晚餐17:00-19:00', 
        phone: '027-87540700' 
      },
      { 
        id: 23, 
        name: '西二食堂二楼', 
        address: '食堂地址：西操场西侧20米', 
        serviceTime: '早餐6:50-9:30，午餐11:00-13:00，晚餐17:00-19:00', 
        phone: '027-87540500' 
      },
      { 
        id: 24, 
        name: '百惠园食堂', 
        address: '食堂地址：紫菘学生公寓入口处', 
        serviceTime: '早餐6:50-9:00，午餐11:00-13:00，晚餐17:00-19:00', 
        phone: '027-87556355' 
      },
      // 24个食堂数据
    ]
  },

  // 搜索框输入事件
  onSearchInput: function(event) {
    const query = event.detail.value.toLowerCase();
    this.setData({ searchQuery: query });
    this.filterCanteens(query);
  },

  // 根据搜索条件筛选食堂
  filterCanteens: function(query) {
    const filteredCanteens = this.data.canteens.filter(canteen => {
      return canteen.name.toLowerCase().includes(query) || 
             canteen.address.toLowerCase().includes(query);
    });
    this.setData({ canteens: filteredCanteens });
  }
});